
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @module pub.session
* @author: Hjava
* @description: Pub模块消息外包
* @since: 2018-07-22 16:11:44
*/
var pub_constant_1 = __webpack_require__(/*! _pub/pub.constant */ "./src/core/pub/pub.constant.ts");
var bufferType_1 = __webpack_require__(/*! _util/bufferType */ "./src/core/utils/bufferType.ts");
var byteBuffer_1 = __webpack_require__(/*! _util/byteBuffer */ "./src/core/utils/byteBuffer.ts");
var constant_1 = __webpack_require__(/*! _util/constant */ "./src/core/utils/constant.ts");
var deviceInfo_1 = __webpack_require__(/*! _util/deviceInfo */ "./src/core/utils/deviceInfo.ts");
var protocol_1 = __webpack_require__(/*! _util/protocol */ "./src/core/utils/protocol.ts");
var timer_1 = __webpack_require__(/*! _util/timer */ "./src/core/utils/timer.ts");
var userData_1 = __webpack_require__(/*! _util/userData */ "./src/core/utils/userData.ts");
var uuid_1 = __webpack_require__(/*! _util/uuid */ "./src/core/utils/uuid.ts");
var PubSession = {};
/**
 * 服务器端透传消息Req
 * @type {Function}
 */
PubSession.PubSendTTReq = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_SEND_TT_REQ,
    init: function () {
        this.deviceType = deviceInfo_1.default.deviceType;
        this.msgUuid = uuid_1.default.next();
        this.fromUid = 0;
        this.toUid = 0;
        this.message;
        this.cts = timer_1.default.get();
        this.msgId = '';
        this.toAppId = 1;
        // 代码上行的透传如果pushType不是2，都不会回调给业务方
        this.pushType = 2;
        this.direction = 1;
        this.retries = 0;
        this.toDeviceTypes = 0;
        this.deviceId = userData_1.default.get('deviceId');
        this.messageReceivedType = constant_1.MESSAGE_RECEIVED_TYPE.PUB_MESSAGE;
        // 本地字段，用于区分PUB透传消息
        this.pubTTMessage = true;
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.msgUuid);
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toUid, bufferType_1.default.LONG);
        this.push(byteBuffer_1.default.strToBytes(this.message), bufferType_1.default.BYTES);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.toAppId, bufferType_1.default.SHORT);
        this.push(this.pushType, bufferType_1.default.SHORT);
        this.push(this.direction, bufferType_1.default.BYTE);
        this.push(this.retries, bufferType_1.default.BYTE);
        this.push(this.toDeviceTypes, bufferType_1.default.BYTE);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.msgUuid = this.popString();
        this.fromUid = this.popLong().value();
        this.toUid = this.popLong().value();
        this.message = this.popBytes();
        this.message = (new byteBuffer_1.default(this.message)).readUTF8String(this.message.byteLength);
        this.cts = this.popLong().value();
        this.msgId = this.popLong();
        this.toAppId = this.popShort();
        this.pushType = this.popShort();
        this.direction = this.popByte();
        this.retries = this.popByte();
        this.toDeviceTypes = this.popByte();
        this.deviceId = this.popString();
    }
});
/**
 * 透传消息Res
 * @type {Function}
 */
PubSession.PubSendTTRes = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_SEND_TT_RES,
    marshall: function () {
        this.push(this.rescode, bufferType_1.default.INT);
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.deviceType, bufferType_1.default.BYTE);
    },
    unmarshall: function () {
        this.rescode = this.popInt();
        this.msgUuid = this.popString();
        this.msgId = this.popLong().value();
        this.cts = this.popLong().value();
        this.deviceType = this.popByte();
    }
});
/**
 * 服务器端消息Req
 * @type {Function}
 */
PubSession.PubSendMsgReq = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_SEND_MSG_REQ,
    init: function () {
        this.uri = pub_constant_1.default.PUB.URI_PUB_SEND_MSG_REQ;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.msgUuid = uuid_1.default.next();
        this.msgId = '';
        this.fromUid = 0;
        this.toUid = 0;
        this.toAppId = 0; //TODO
        this.type;
        this.message;
        this.fromName = ''; //nickname
        this.cts = timer_1.default.get();
        this.pushType = 0;
        this.direction = 1;
        this.extension = '';
        this.retries = 0;
        this.toDeviceTypes = 0;
        this.channel = 0;
        this.sessionSeqId = '';
        this.compatible = '';
        this.deviceId = userData_1.default.get('deviceId');
        this.messageReceivedType = constant_1.MESSAGE_RECEIVED_TYPE.PUB_MESSAGE;
    },
    setUid: function (uid) {
        this.fromUid = uid;
    },
    initAfter: function () {
        this.message && (this.type = this.type || this.message.__type);
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.msgUuid); //客户端消息ID
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toUid, bufferType_1.default.LONG);
        this.push(this.toAppId, bufferType_1.default.SHORT);
        this.push(this.message.__type); //消息类型
        this.push(this.message);
        this.push(this.fromName);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.pushType);
        this.push(this.direction, bufferType_1.default.BYTE);
        this.push(this.extension);
        this.push(this.retries, bufferType_1.default.BYTE);
        this.push(this.toDeviceTypes, bufferType_1.default.BYTE);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
        this.push(this.compatible, bufferType_1.default.STRING);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.msgUuid = this.popString();
        this.msgId = this.popLong();
        this.fromUid = this.popLong().value();
        this.toUid = this.popLong().value();
        this.toAppId = this.popShort();
        this.type = this.popInt();
        this.message = protocol_1.default.Message.fromBuffer(this.popBytes());
        this.fromName = this.popString();
        this.cts = this.popLong().value();
        this.pushType = this.popInt();
        this.direction = this.popByte();
        this.extension = this.popString();
        this.retries = this.popByte();
        this.toDeviceTypes = this.popByte();
        this.channel = this.popShort();
        this.sessionSeqId = this.popLong().value();
        this.compatible = this.popString();
        this.deviceId = this.popString();
        var channelMap = userData_1.default.get('channelMap');
        if (channelMap && (!this.channel || this.channel === 0)) {
            if (this.fromUid === userData_1.default.get('uid')) {
                this.channel = channelMap[this.toAppId] || 0;
            }
            else {
                this.channel = channelMap[this.appid] || 0;
            }
        }
    }
});
/**
 * 服务器端消息Req-客服
 * @type {Function}
 */
PubSession.PubSendMsgKFReq = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_SEND_MSG_KF_REQ,
    init: function () {
        this.uri = pub_constant_1.default.PUB.URI_PUB_SEND_MSG_KF_REQ;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.msgUuid = uuid_1.default.next();
        this.msgId = '';
        this.senderUid = 0;
        this.receiverUid = 0;
        this.receiverAppId = 0;
        this.pubUid = 0;
        this.type;
        this.message;
        this.fromName = '';
        this.cts = timer_1.default.get();
        this.pushType = 0;
        this.direction = 1;
        this.extension = '';
        this.retries = 0;
        this.toDeviceTypes = 0;
        this.channel = 0;
        this.sessionSeqId = '';
        this.compatible = '';
        this.deviceId = userData_1.default.get('deviceId');
        this.messageReceivedType = constant_1.MESSAGE_RECEIVED_TYPE.KEFU_MESSAGE;
    },
    setUid: function (uid) {
        this.senderUid = uid;
    },
    initAfter: function () {
        this.message && (this.type = this.type || this.message.__type);
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.msgUuid); //客户端消息ID
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.senderUid, bufferType_1.default.LONG);
        this.push(this.receiverUid, bufferType_1.default.LONG);
        this.push(this.receiverAppId, bufferType_1.default.SHORT);
        this.push(this.pubUid, bufferType_1.default.LONG);
        this.push(this.message.__type);
        this.push(this.message);
        this.push(this.fromName);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.pushType);
        this.push(this.direction, bufferType_1.default.BYTE);
        this.push(this.extension);
        this.push(this.retries, bufferType_1.default.BYTE);
        this.push(this.toDeviceTypes, bufferType_1.default.BYTE);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
        this.push(this.compatible, bufferType_1.default.STRING);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.msgUuid = this.popString();
        this.msgId = this.popLong();
        this.senderUid = this.popLong().value();
        this.receiverUid = this.popLong().value();
        this.receiverAppId = this.popShort();
        this.pubUid = this.popLong().value();
        this.type = this.popInt();
        this.message = protocol_1.default.Message.fromBuffer(this.popBytes());
        this.fromName = this.popString();
        this.cts = this.popLong().value();
        this.pushType = this.popInt();
        this.direction = this.popByte();
        this.extension = this.popString();
        this.retries = this.popByte();
        this.toDeviceTypes = this.popByte();
        this.channel = this.popShort();
        this.sessionSeqId = this.popLong().value();
        this.compatible = this.popString();
        this.deviceId = this.popString();
        var channelMap = userData_1.default.get('channelMap');
        if (channelMap && (!this.channel || this.channel === 0)) {
            if (this.senderUid === userData_1.default.get('uid')) {
                this.channel = channelMap[this.receiverAppId] || 0;
            }
            else {
                this.channel = channelMap[this.appid] || 0;
            }
        }
    }
});
/**
 * 服务器端消息Res (系统号/订阅号-Ack)
 * @type {Function}
 */
PubSession.PubSendMsgRes = protocol_1.default.Response.extend({
    category: 'PUB',
    __master: true,
    uri: pub_constant_1.default.PUB.URI_PUB_SEND_MSG_RES,
    init: function () {
        this.rescode = 0;
        this.msgUuid = '';
        this.msgId = '';
        this.cts = '';
        this.deviceType = deviceInfo_1.default.deviceType;
        this.sessionSeqId = '';
    },
    marshall: function () {
        this.push(this.rescode, bufferType_1.default.INT);
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
    },
    unmarshall: function () {
        this.rescode = this.popInt();
        this.msgUuid = this.popString();
        this.msgId = this.popLong().value();
        this.cts = this.popLong().value();
        this.deviceType = this.popByte();
        this.sessionSeqId = this.popLong().value();
    }
});
/**
 * 服务器端消息Res (客服号-Ack)
 * @type {Function}
 */
PubSession.PubSendMsgKFRes = protocol_1.default.Response.extend({
    category: 'PUB',
    __master: true,
    uri: pub_constant_1.default.PUB.URI_PUB_SEND_MSG_KF_RES,
    init: function () {
        this.rescode = 0;
        this.msgUuid = '';
        this.msgId = '';
        this.cts = '';
        this.deviceType = deviceInfo_1.default.deviceType;
        this.sessionSeqId = '';
    },
    marshall: function () {
        this.push(this.rescode, bufferType_1.default.INT);
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
    },
    unmarshall: function () {
        this.rescode = this.popInt();
        this.msgUuid = this.popString();
        this.msgId = this.popLong().value();
        this.cts = this.popLong().value();
        this.deviceType = this.popByte();
        this.sessionSeqId = this.popLong().value();
    }
});
/**
 * 服务器端广播消息Req
 * @type {Function}
 */
PubSession.PubBroadcastMsgReq = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_BC_MSG_REQ,
    init: function () {
        this.uri = pub_constant_1.default.PUB.URI_PUB_BC_MSG_REQ;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.msgUuid = uuid_1.default.next();
        this.msgId = '';
        this.fromUid = 0;
        this.toAppId = 1; //TODO
        this.type;
        this.message;
        this.cts = timer_1.default.get();
        this.pushType = 0; //meanless
        this.delta = 0;
        this.extension = '';
    },
    setUid: function (uid) {
        this.fromUid = uid;
    },
    initAfter: function () {
        this.message && (this.type = this.type || this.message.__type);
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.msgUuid); //客户端消息ID
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toAppId, bufferType_1.default.SHORT);
        this.push(this.message.__type); //消息类型
        this.push(this.message);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.pushType);
        this.push(this.delta);
        this.push(this.extension);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.msgUuid = this.popString();
        this.msgId = this.popLong();
        this.fromUid = this.popLong().value();
        this.toAppId = this.popShort();
        this.type = this.popInt();
        this.message = protocol_1.default.Message.fromBuffer(this.popBytes());
        this.cts = this.popLong().value();
        this.pushType = this.popInt();
        this.delta = this.popInt();
        this.extension = this.popString();
    }
});
PubSession.PubMarkReads = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_MARK_READS,
    init: function () {
        this.uri = pub_constant_1.default.PUB.URI_PUB_MARK_READS;
        this.uid = '';
        this.deviceType = deviceInfo_1.default.deviceType;
        this.markReads = [];
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.markReads, bufferType_1.default.ARRAY_ARRAY);
    },
    unmarshall: function () {
        this.uid = this.popLong().value();
        this.deviceType = this.popByte();
        var byteItems = this._popArrayArray();
        for (var i = 0; i < byteItems.length; i++) {
            this.markReads.push((new PubSession.PubMarkRead().parserFromBuffer(byteItems[i])));
        }
    }
});
/**
 * 标记已读未读消息
 */
PubSession.PubMarkRead = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_MARK_READ,
    init: function () {
        this.uri = pub_constant_1.default.PUB.URI_PUB_MARK_READ;
        this.uid = 0;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.chatId = 0;
        this.peerUid = 0;
        this.opt = 1;
        this.channel = 0;
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.chatId, bufferType_1.default.LONG);
        this.push(this.peerUid, bufferType_1.default.LONG);
        this.push(this.opt, bufferType_1.default.BYTE);
        this.push(this.channel, bufferType_1.default.SHORT);
    },
    unmarshall: function () {
        this.uid = this.popLong().value();
        this.deviceType = this.popByte();
        this.chatId = this.popLong().value();
        this.peerUid = this.popLong().value();
        this.opt = this.popByte();
        this.channel = this.popShort();
    }
});
/**
 * 服务器端广播消息Notify
 * @type {Function}
 */
PubSession.PubBroadcastNotify = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_BC_NOTIFY,
    init: function () {
        this.uri = pub_constant_1.default.PUB.URI_PUB_BC_NOTIFY;
        this.fromUid = 0;
        this.toAppId = 1;
        this.msgId = '';
        this.delta = 0;
    },
    setUid: function (uid) {
        this.fromUid = uid;
    },
    marshall: function () {
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toAppId, bufferType_1.default.SHORT);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.delta);
    },
    unmarshall: function () {
        this.fromUid = this.popLong().value();
        this.toAppId = this.popShort();
        this.msgId = this.popLong();
        this.delta = this.popInt();
    }
});
/**
 * 回服务器端消息Res(Ack)
 * @type {Function}
 */
PubSession.PubAckMsgs = protocol_1.default.Request.extend({
    category: 'PUB',
    __master: true,
    init: function () {
        this.uri = pub_constant_1.default.PUB.URI_PUB_ACK_MSGS;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.uid = 0;
        this.msgIds = [];
        this.msgCategory = 1;
        // 客户端收到 ACK 时间
        this.timeReceived = Date.now();
        this.timeAck = '';
        this.deviceId = userData_1.default.get('deviceId');
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.msgIds);
        this.push(this.msgCategory, bufferType_1.default.BYTE);
        this.push(this.timeReceived, bufferType_1.default.LONG);
        this.push(this.timeAck, bufferType_1.default.LONG);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.uid = this.popLong().value();
        this.msgIds = this._popArrayLong();
        this.msgCategory = this.popByte();
        this.timeReceived = this.popLong().value();
        this.timeAck = this.popLong().value();
        this.deviceId = this.popString();
    }
});
/**
 * 回服务器端消息同步Res(Ack)
 * @type {Function}
 */
PubSession.PubAckSyncMsgs = protocol_1.default.Request.extend({
    category: 'PUB',
    __master: true,
    init: function () {
        this.uri = pub_constant_1.default.PUB.URI_PUB_ACK_SYNC_MSGS;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.uid = 0;
        this.msgIds = [];
        this.msgCategory = 1;
        this.deviceId = userData_1.default.get('deviceId');
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.msgIds);
        this.push(this.msgCategory, bufferType_1.default.BYTE);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.uid = this.popLong().value();
        this.msgIds = this._popArrayLong();
        this.msgCategory = this.popByte();
        this.deviceId = this.popString();
    }
});
/**
 * 服务器端已读同步Req
 * @type {Function}
 */
PubSession.PubSyncRead = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_SYNC_READ,
    init: function () {
        this.uri = pub_constant_1.default.PUB.URI_PUB_SYNC_READ;
        this.uid = 0;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.syncReadItems = [];
        this.msgUuid = uuid_1.default.next();
        this.deviceId = userData_1.default.get('deviceId');
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.syncReadItems, bufferType_1.default.ARRAY_ARRAY);
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.uid = this.popLong().value();
        this.deviceType = this.popByte();
        var byteItems = this._popArrayArray();
        for (var i = 0; i < byteItems.length; i++) {
            this.syncReadItems.push(protocol_1.default.Response.fromBuffer(byteItems[i]));
        }
        this.msgUuid = this.popString();
        this.deviceId = this.popString();
    }
});
/**
 * 服务器端已读同步项-基于时间戳
 * @type {Function}
 */
PubSession.PubSyncReadItem = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_SYNC_READ_ITEM,
    init: function () {
        this.uri = pub_constant_1.default.PUB.URI_PUB_SYNC_READ_ITEM;
        this.chatId = 0;
        this.stamp = timer_1.default.get();
        this.type = 0;
        this.peerUid = 0;
        this.peerAppId = 0;
        this.sts = 0;
        this.channel = 0;
    },
    marshall: function () {
        this.push(this.chatId, bufferType_1.default.LONG);
        this.push(this.stamp, bufferType_1.default.LONG);
        this.push(this.type, bufferType_1.default.BYTE);
        this.push(this.peerUid, bufferType_1.default.LONG);
        this.push(this.peerAppId, bufferType_1.default.SHORT);
        this.push(this.sts, bufferType_1.default.LONG);
        this.push(this.channel, bufferType_1.default.SHORT);
    },
    unmarshall: function () {
        this.chatId = this.popLong().value();
        this.stamp = this.popLong().value();
        this.type = this.popByte();
        this.peerUid = this.popLong().value();
        this.peerAppId = this.popShort();
        this.sts = this.popLong().value();
        this.channel = this.popShort();
    }
});
PubSession.PubSyncReadRes = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_SYNC_READ_RES,
    init: function () {
        this.msgUuid = uuid_1.default.next();
    },
    marshall: function () {
        this.push(this.msgUuid, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.msgUuid = this.popString();
    }
});
/**
 * 服务器端已读同步项-基于消息id
 * @type {Function}
 */
PubSession.PubSyncReadMsgs = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_SYNC_READ_MSGS,
    init: function () {
        this.uri = pub_constant_1.default.PUB.URI_PUB_SYNC_READ_MSGS;
        this.chatId = 0;
        this.msgIds = [];
        this.type = 0;
        this.peerUid = 0;
        this.peerAppId = 0;
    },
    marshall: function () {
        this.push(this.chatId, bufferType_1.default.LONG);
        this.push(this.msgIds);
        this.push(this.type, bufferType_1.default.BYTE);
        this.push(this.peerUid, bufferType_1.default.LONG);
        this.push(this.peerAppId, bufferType_1.default.SHORT);
    },
    unmarshall: function () {
        this.chatId = this.popLong().value();
        this.msgIds = this._popArrayLong();
        this.type = this.popByte();
        this.peerUid = this.popLong().value();
        this.peerAppId = this.popShort();
    }
});
/**
 * 用于客户端撤销已发送Pub消息的协议
 * @type {Function}
 */
PubSession.PubCancelMsg = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_CANCEL_MSG,
    init: function () {
        this.deviceType = deviceInfo_1.default.deviceType;
        this.msgUuid = '';
        this.fromUid = '';
        this.toUid = '';
        this.fromName = '';
        this.cts = timer_1.default.get();
        this.msgId = '';
        this.toAppId = 0; // 接收人APPID
        this.direction = 1; // 消息方向: 1表示个人向公众号发消息，2表示公众号向个人发消息
        this.extension = '';
        this.channel = 0;
        this.isforce = false;
        this.sts = '';
        this.sessionSeqId = '';
        this.messageReceivedType = constant_1.MESSAGE_RECEIVED_TYPE.CANCEL_PUB_MESSAGE;
        this.deviceId = '';
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toUid, bufferType_1.default.LONG);
        this.push(this.fromName, bufferType_1.default.STRING);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.toAppId, bufferType_1.default.SHORT);
        this.push(this.direction, bufferType_1.default.BYTE);
        this.push(this.extension, bufferType_1.default.STRING);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.isforce, bufferType_1.default.SHORT);
        this.push(this.sts, bufferType_1.default.LONG);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.msgUuid = this.popString();
        this.fromUid = this.popLong().value();
        this.toUid = this.popLong().value();
        this.fromName = this.popString();
        this.cts = this.popLong().value();
        this.msgId = this.popLong().value();
        this.toAppId = this.popShort();
        this.direction = this.popByte();
        this.extension = this.popString();
        this.channel = this.popShort();
        this.isforce = this.popShort();
        this.sts = this.popLong().value();
        this.sessionSeqId = this.popLong().value();
        this.deviceId = this.popString();
    }
});
/**
 * 客户端对服务端发来的PubCancelMsg的回复
 * @type {Function}
 */
PubSession.PubCancelMsgRes = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_CANCEL_MSG_RES,
    init: function () {
        this.msgUuid = '';
        this.msgId = '';
        this.cts = timer_1.default.get();
        this.rescode = '';
        this.deviceType = deviceInfo_1.default.deviceType;
        this.sts = '';
    },
    marshall: function () {
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.rescode, bufferType_1.default.INT);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.sts, bufferType_1.default.LONG);
    },
    unmarshall: function () {
        this.msgUuid = this.popString();
        this.msgId = this.popLong();
        this.cts = this.popLong().value();
        this.rescode = this.popInt();
        this.deviceType = this.popByte();
        this.sts = this.popLong().value();
    }
});
PubSession.PubOppositeSyncRead = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_OPPOSITE_READ,
    init: function () {
        this.uid = '';
        this.oppositeUuid = uuid_1.default.next();
        this.deviceType = deviceInfo_1.default.deviceType;
        this.syncReadItems = [];
        this.deviceId = userData_1.default.get('deviceId');
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.oppositeUuid, bufferType_1.default.STRING);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.syncReadItems, bufferType_1.default.ARRAY_ARRAY);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.uid = this.popLong().value();
        this.oppositeUuid = this.popString();
        this.deviceType = this.popByte();
        var byteItems = this._popArrayArray();
        for (var i = 0; i < byteItems.length; i++) {
            this.syncReadItems.push(protocol_1.default.Response.fromBuffer(byteItems[i]));
        }
        this.deviceId = this.popString();
    }
});
PubSession.PubOppositeSyncReadItem = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_OPPOSITE_READ_TS_ITEM,
    init: function () {
        this.chatId = '';
        this.type = 0;
        this.peerUid = '';
        this.peerAppId = 0;
        this.channel = 0;
        this.sts = 0;
    },
    marshall: function () {
        this.push(this.chatId, bufferType_1.default.LONG);
        this.push(this.type, bufferType_1.default.BYTE);
        this.push(this.peerUid, bufferType_1.default.LONG);
        this.push(this.peerAppId, bufferType_1.default.SHORT);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.sts, bufferType_1.default.LONG);
    },
    unmarshall: function () {
        this.chatId = this.popLong().value();
        this.type = this.popByte();
        this.peerUid = this.popLong().value();
        this.peerAppId = this.popShort();
        this.channel = this.popShort();
        this.sts = this.popLong().value();
    }
});
PubSession.PubOppositeSyncReadRes = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_OPPOSITE_READ_RES,
    init: function () {
        this.uid = '';
        this.oppositeUuid = uuid_1.default.next();
        this.deviceType = deviceInfo_1.default.deviceType;
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.oppositeUuid, bufferType_1.default.STRING);
        this.push(this.deviceType, bufferType_1.default.BYTE);
    },
    unmarshall: function () {
        this.uid = this.popLong().value();
        this.oppositeUuid = this.popString();
        this.deviceType = this.popByte();
    }
});
PubSession.PubCancelMsg2 = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_CANCEL_MSG2,
    init: function () {
        this.version = 2;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.msgUuid = '';
        this.fromUid = '';
        this.toUid = '';
        this.fromName = '';
        this.cts = timer_1.default.get();
        this.msgId = '';
        this.toAppId = 0; // 接收人APPID
        this.direction = 1; // 消息方向: 1表示个人向公众号发消息，2表示公众号向个人发消息
        this.extension = '';
        this.channel = 0;
        this.isforce = false;
        this.sts = '';
        this.sessionSeqId = '';
        this.sid = '';
        this.messageReceivedType = constant_1.MESSAGE_RECEIVED_TYPE.CANCEL_PUB_MESSAGE2;
        this.deviceId = '';
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toUid, bufferType_1.default.LONG);
        this.push(this.fromName, bufferType_1.default.STRING);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.toAppId, bufferType_1.default.SHORT);
        this.push(this.direction, bufferType_1.default.BYTE);
        this.push(this.extension, bufferType_1.default.STRING);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.isforce, bufferType_1.default.SHORT);
        this.push(this.sts, bufferType_1.default.LONG);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
        this.push(this.sid, bufferType_1.default.STRING);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.msgUuid = this.popString();
        this.fromUid = this.popLong().value();
        this.toUid = this.popLong().value();
        this.fromName = this.popString();
        this.cts = this.popLong().value();
        this.msgId = this.popLong().value();
        this.toAppId = this.popShort();
        this.direction = this.popByte();
        this.extension = this.popString();
        this.channel = this.popShort();
        this.isforce = this.popShort();
        this.sts = this.popLong().value();
        this.sessionSeqId = this.popLong().value();
        this.sid = this.popString();
        this.deviceId = this.popString();
    }
});
PubSession.PubOppositeSyncRead2 = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_OPPOSITE_READ2,
    init: function () {
        this.version = 2;
        this.uid = '';
        this.oppositeUuid = uuid_1.default.next();
        this.deviceType = deviceInfo_1.default.deviceType;
        this.syncReadItems = [];
        this.deviceId = userData_1.default.get('deviceId');
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.oppositeUuid, bufferType_1.default.STRING);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.syncReadItems, bufferType_1.default.ARRAY_ARRAY);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.uid = this.popLong().value();
        this.oppositeUuid = this.popString();
        this.deviceType = this.popByte();
        var byteItems = this._popArrayArray();
        for (var i = 0; i < byteItems.length; i++) {
            this.syncReadItems.push(protocol_1.default.Response.fromBuffer(byteItems[i], 2));
        }
        this.deviceId = this.popString();
    }
});
PubSession.PubOppositeSyncReadItem2 = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_OPPOSITE_READ_TS_ITEM2,
    init: function () {
        this.version = 2;
        this.chatId = '';
        this.type = 0;
        this.peerUid = '';
        this.peerAppId = 0;
        this.channel = 0;
        this.sts = 0;
        this.sid = '';
    },
    marshall: function () {
        this.push(this.chatId, bufferType_1.default.LONG);
        this.push(this.type, bufferType_1.default.BYTE);
        this.push(this.peerUid, bufferType_1.default.LONG);
        this.push(this.peerAppId, bufferType_1.default.SHORT);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.sts, bufferType_1.default.LONG);
        this.push(this.sid, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.chatId = this.popLong().value();
        this.type = this.popByte();
        this.peerUid = this.popLong().value();
        this.peerAppId = this.popShort();
        this.channel = this.popShort();
        this.sts = this.popLong().value();
        this.sid = this.popString();
    }
});
PubSession.PubSendMsgKFReq2 = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_SEND_MSG_KF_REQ2,
    init: function () {
        this.version = 2;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.msgUuid = uuid_1.default.next();
        this.msgId = '';
        this.senderUid = 0;
        this.receiverUid = 0;
        this.receiverAppId = 0;
        this.pubUid = 0;
        this.type;
        this.message;
        this.fromName = '';
        this.cts = timer_1.default.get();
        this.pushType = 0;
        this.direction = 1;
        this.extension = '';
        this.retries = 0;
        this.toDeviceTypes = 0;
        this.channel = 0;
        this.sessionSeqId = '';
        this.compatible = '';
        this.deviceId = userData_1.default.get('deviceId');
        this.sid = '';
        this.messageReceivedType = constant_1.MESSAGE_RECEIVED_TYPE.KEFU_MESSAGE2;
    },
    setUid: function (uid) {
        this.senderUid = uid;
    },
    initAfter: function () {
        this.message && (this.type = this.type || this.message.__type);
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.msgUuid); //客户端消息ID
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.senderUid, bufferType_1.default.LONG);
        this.push(this.receiverUid, bufferType_1.default.LONG);
        this.push(this.receiverAppId, bufferType_1.default.SHORT);
        this.push(this.pubUid, bufferType_1.default.LONG);
        this.push(this.message.__type);
        this.push(this.message);
        this.push(this.fromName);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.pushType);
        this.push(this.direction, bufferType_1.default.BYTE);
        this.push(this.extension);
        this.push(this.retries, bufferType_1.default.BYTE);
        this.push(this.toDeviceTypes, bufferType_1.default.BYTE);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
        this.push(this.compatible, bufferType_1.default.STRING);
        this.push(this.deviceId, bufferType_1.default.STRING);
        this.push(this.sid, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.msgUuid = this.popString();
        this.msgId = this.popLong();
        this.senderUid = this.popLong().value();
        this.receiverUid = this.popLong().value();
        this.receiverAppId = this.popShort();
        this.pubUid = this.popLong().value();
        this.type = this.popInt();
        this.message = protocol_1.default.Message.fromBuffer(this.popBytes());
        this.fromName = this.popString();
        this.cts = this.popLong().value();
        this.pushType = this.popInt();
        this.direction = this.popByte();
        this.extension = this.popString();
        this.retries = this.popByte();
        this.toDeviceTypes = this.popByte();
        this.channel = this.popShort();
        this.sessionSeqId = this.popLong().value();
        this.compatible = this.popString();
        this.deviceId = this.popString();
        this.sid = this.popString();
        var channelMap = userData_1.default.get('channelMap');
        if (channelMap && (!this.channel || this.channel === 0)) {
            if (this.senderUid === userData_1.default.get('uid')) {
                this.channel = channelMap[this.receiverAppId] || 0;
            }
            else {
                this.channel = channelMap[this.appid] || 0;
            }
        }
    }
});
PubSession.PubSendMsgReq2 = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_SEND_MSG_REQ2,
    init: function () {
        this.version = 2;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.msgUuid = uuid_1.default.next();
        this.msgId = '';
        this.fromUid = 0;
        this.toUid = 0;
        this.toAppId = 0; //TODO
        this.type;
        this.message;
        this.fromName = ''; //nickname
        this.cts = timer_1.default.get();
        this.pushType = 0;
        this.direction = 1;
        this.extension = '';
        this.retries = 0;
        this.toDeviceTypes = 0;
        this.channel = 0;
        this.sessionSeqId = '';
        this.compatible = '';
        this.deviceId = userData_1.default.get('deviceId');
        this.sid = '';
        this.messageReceivedType = constant_1.MESSAGE_RECEIVED_TYPE.PUB_MESSAGE2;
    },
    setUid: function (uid) {
        this.fromUid = uid;
    },
    initAfter: function () {
        this.message && (this.type = this.type || this.message.__type);
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.msgUuid); //客户端消息ID
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toUid, bufferType_1.default.LONG);
        this.push(this.toAppId, bufferType_1.default.SHORT);
        this.push(this.message.__type); //消息类型
        this.push(this.message);
        this.push(this.fromName);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.pushType);
        this.push(this.direction, bufferType_1.default.BYTE);
        this.push(this.extension);
        this.push(this.retries, bufferType_1.default.BYTE);
        this.push(this.toDeviceTypes, bufferType_1.default.BYTE);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
        this.push(this.compatible, bufferType_1.default.STRING);
        this.push(this.deviceId, bufferType_1.default.STRING);
        this.push(this.sid, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.msgUuid = this.popString();
        this.msgId = this.popLong();
        this.fromUid = this.popLong().value();
        this.toUid = this.popLong().value();
        this.toAppId = this.popShort();
        this.type = this.popInt();
        this.message = protocol_1.default.Message.fromBuffer(this.popBytes());
        this.fromName = this.popString();
        this.cts = this.popLong().value();
        this.pushType = this.popInt();
        this.direction = this.popByte();
        this.extension = this.popString();
        this.retries = this.popByte();
        this.toDeviceTypes = this.popByte();
        this.channel = this.popShort();
        this.sessionSeqId = this.popLong().value();
        this.compatible = this.popString();
        this.deviceId = this.popString();
        this.sid = this.popString();
        var channelMap = userData_1.default.get('channelMap');
        if (channelMap && (!this.channel || this.channel === 0)) {
            if (this.fromUid === userData_1.default.get('uid')) {
                this.channel = channelMap[this.toAppId] || 0;
            }
            else {
                this.channel = channelMap[this.appid] || 0;
            }
        }
    }
});
PubSession.PubSyncRead2 = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_SYNC_READ2,
    init: function () {
        this.version = 2;
        this.uid = 0;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.syncReadItems = [];
        this.msgUuid = uuid_1.default.next();
        this.deviceId = userData_1.default.get('deviceId');
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.syncReadItems, bufferType_1.default.ARRAY_ARRAY);
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.uid = this.popLong().value();
        this.deviceType = this.popByte();
        var byteItems = this._popArrayArray();
        for (var i = 0; i < byteItems.length; i++) {
            this.syncReadItems.push(protocol_1.default.Response.fromBuffer(byteItems[i], 2));
        }
        this.msgUuid = this.popString();
        this.deviceId = this.popString();
    }
});
PubSession.PubSyncReadItem2 = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_SYNC_READ_ITEM2,
    init: function () {
        this.uri = pub_constant_1.default.PUB.URI_PUB_SYNC_READ_ITEM2;
        this.version = 2;
        this.chatId = 0;
        this.stamp = timer_1.default.get();
        this.type = 0;
        this.peerUid = 0;
        this.peerAppId = 0;
        this.sts = 0;
        this.channel = 0;
        this.sid = '';
    },
    marshall: function () {
        this.push(this.chatId, bufferType_1.default.LONG);
        this.push(this.stamp, bufferType_1.default.LONG);
        this.push(this.type, bufferType_1.default.BYTE);
        this.push(this.peerUid, bufferType_1.default.LONG);
        this.push(this.peerAppId, bufferType_1.default.SHORT);
        this.push(this.sts, bufferType_1.default.LONG);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.sid, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.chatId = this.popLong().value();
        this.stamp = this.popLong().value();
        this.type = this.popByte();
        this.peerUid = this.popLong().value();
        this.peerAppId = this.popShort();
        this.sts = this.popLong().value();
        this.channel = this.popShort();
        this.sid = this.popString();
    }
});
/**
 * 用于客户端撤销已发送Pub的客服侧消息的协议
 * @type {Function}
 */
PubSession.PubCancelKFMsg = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_CANCEL_KF_MSG,
    init: function () {
        this.deviceType = deviceInfo_1.default.deviceType;
        this.msgUuid = '';
        this.fromUid = '';
        this.toUid = '';
        this.pubUid = '';
        this.fromName = '';
        this.cts = timer_1.default.get();
        this.msgId = '';
        this.toAppId = 0; // 接收人APPID
        this.direction = 1; // 消息方向: 1表示个人向公众号发消息，2表示公众号向个人发消息
        this.extension = '';
        this.channel = 0;
        this.isforce = false;
        this.sts = '';
        this.sessionSeqId = '';
        this.messageReceivedType = constant_1.MESSAGE_RECEIVED_TYPE.CANCEL_PUB_KF_MESSAGE;
        this.deviceId = '';
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toUid, bufferType_1.default.LONG);
        this.push(this.pubUid, bufferType_1.default.LONG);
        this.push(this.fromName, bufferType_1.default.STRING);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.toAppId, bufferType_1.default.SHORT);
        this.push(this.direction, bufferType_1.default.BYTE);
        this.push(this.extension, bufferType_1.default.STRING);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.isforce, bufferType_1.default.SHORT);
        this.push(this.sts, bufferType_1.default.LONG);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.msgUuid = this.popString();
        this.fromUid = this.popLong().value();
        this.toUid = this.popLong().value();
        this.pubUid = this.popLong().value();
        this.fromName = this.popString();
        this.cts = this.popLong().value();
        this.msgId = this.popLong().value();
        this.toAppId = this.popShort();
        this.direction = this.popByte();
        this.extension = this.popString();
        this.channel = this.popShort();
        this.isforce = this.popShort();
        this.sts = this.popLong().value();
        this.sessionSeqId = this.popLong().value();
        this.deviceId = this.popString();
    }
});
/**
 * 收到服务端发来的回复
 * @type {Function}
 */
PubSession.PubCancelKFMsgRes = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_CANCEL_KF_MSG_RES,
    init: function () {
        this.msgUuid = '';
        this.msgId = '';
        this.cts = timer_1.default.get();
        this.rescode = '';
        this.deviceType = deviceInfo_1.default.deviceType;
        this.sts = '';
    },
    marshall: function () {
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.rescode, bufferType_1.default.INT);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.sts, bufferType_1.default.LONG);
    },
    unmarshall: function () {
        this.msgUuid = this.popString();
        this.msgId = this.popLong();
        this.cts = this.popLong().value();
        this.rescode = this.popInt();
        this.deviceType = this.popByte();
        this.sts = this.popLong().value();
    }
});
PubSession.PubCancelKFMsg2 = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_CANCEL_KF_MSG2,
    init: function () {
        this.version = 2;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.msgUuid = '';
        this.fromUid = '';
        this.toUid = '';
        this.pubUid = '';
        this.fromName = '';
        this.cts = timer_1.default.get();
        this.msgId = '';
        this.toAppId = 0; // 接收人APPID
        this.direction = 1; // 消息方向: 1表示个人向公众号发消息，2表示公众号向个人发消息
        this.extension = '';
        this.channel = 0;
        this.isforce = false;
        this.sts = '';
        this.sessionSeqId = '';
        this.sid = '';
        this.messageReceivedType = constant_1.MESSAGE_RECEIVED_TYPE.CANCEL_PUB_KF_MESSAGE2;
        this.deviceId = '';
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toUid, bufferType_1.default.LONG);
        this.push(this.pubUid, bufferType_1.default.LONG);
        this.push(this.fromName, bufferType_1.default.STRING);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.toAppId, bufferType_1.default.SHORT);
        this.push(this.direction, bufferType_1.default.BYTE);
        this.push(this.extension, bufferType_1.default.STRING);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.isforce, bufferType_1.default.SHORT);
        this.push(this.sts, bufferType_1.default.LONG);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
        this.push(this.sid, bufferType_1.default.STRING);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.msgUuid = this.popString();
        this.fromUid = this.popLong().value();
        this.toUid = this.popLong().value();
        this.pubUid = this.popLong().value();
        this.fromName = this.popString();
        this.cts = this.popLong().value();
        this.msgId = this.popLong().value();
        this.toAppId = this.popShort();
        this.direction = this.popByte();
        this.extension = this.popString();
        this.channel = this.popShort();
        this.isforce = this.popShort();
        this.sts = this.popLong().value();
        this.sessionSeqId = this.popLong().value();
        this.sid = this.popString();
        this.deviceId = this.popString();
    }
});
PubSession.PubMessageAddition2 = protocol_1.default.Response.extend({
    category: 'PUB',
    uri: pub_constant_1.default.PUB.URI_PUB_ADDITION_MSG2,
    init: function () {
        this.version = 2;
        this.msgUuid = '';
        this.fromUid = '';
        this.deviceType = deviceInfo_1.default.deviceType;
        this.deviceId = userData_1.default.get('deviceId');
        this.msgId = '';
        this.channel = 0;
        this.additionData = '';
        this.receivers = [];
        this.receiverAppId = '';
        this.sts = '';
        this.seqId = 0;
        this.allowAddition = false;
    },
    unmarshall: function () {
        this.msgUuid = this.popString();
        this.fromUid = this.popLong().value();
        this.deviceType = this.popByte();
        this.deviceId = this.popString();
        this.msgId = this.popLong().value();
        this.channel = this.popShort();
        this.additionData = this.popString();
        this.receivers = this._popArrayLong();
        this.receiverAppId = this.popShort();
        this.sts = this.popLong().value();
        this.seqId = this.popInt();
        this.allowAddition = this.popBool();
    }
});
exports.default = PubSession;


//# sourceURL=webpack://MTDX/./src/core/pub/pub.session.ts?